﻿using System;
using System.Collections.Generic;

namespace Sherwood.Content.UpdateServices.Attachments.Tests
{
    public class MyAttachmentMeta : IAttachmentMeta
    {
        private readonly List<MyAttachment> _attachments = new List<MyAttachment>();

        public MyAttachmentMeta()
        {
            Id = Guid.NewGuid();
        }

        public Guid Id { get; private set; }
        public string UsageKey { get; set; }
        public IRecord Record { get; private set; }
        public IClient Client { get; private set; }
        public DateTime DateCreated { get; private set; }
        public DateTime DateModified { get; private set; }

        public void ClearAttachments()
        {
            _attachments.Clear();
        }

        public IAttachment GetAttachmentById(string referenceId)
        {
            return null;
        }

        public IAttachment CreateNewAttachment(string referenceId)
        {
            var attachment = new MyAttachment {ReferenceId = referenceId};
            _attachments.Add(attachment);
            return attachment;
        }

        public IEnumerable<IAttachment> GetAttachments()
        {
            return _attachments;
        }

        public void DeleteAttachment(string referenceId)
        {
            _attachments.RemoveAll(a => a.ReferenceId == referenceId);
        }
    }
}